const Router = require('koa-router')
const reqlib = require('app-root-path').require
const config = reqlib('/config/index')
const controllers = require('../controllers')

const projectName = config.project.projectName
if (!projectName) {
  console.error('projectName is required')
  process.exit()
}
const router = new Router({
  prefix: `/${projectName}`
})

/**
 * 端口测试
 */
router.get('/', async function (ctx) {
  ctx.body = `ok ${projectName}`
})
/**
 * 系统模块
 */
router.get('/sys/getDictionaryByKey', controllers.sysController.getDictionaryByKey)
router.get('/sys/getDictionaryByKeyList', controllers.sysController.getDictionaryByKeyList)
router.post('/sys/updateDictionaryByKey', controllers.sysController.updateDictionaryByKey)
router.post('/sys/proxyUrl', controllers.sysController.proxyUrl)
router.get('/sys/getErrMsgsByPaging', controllers.sysController.getErrMsgsByPaging)
/**
 * 定时任务模块
 */
router.post('/schedule/add', controllers.scheduleController.addSchedule)
router.get('/schedule/delete', controllers.scheduleController.deleteSchedule)
router.post('/schedule/update', controllers.scheduleController.updateSchedule)
router.post('/schedule/changeStatus', controllers.scheduleController.changeScheduleStatus)
router.get('/schedule/all', controllers.scheduleController.getSchedules)
router.get('/schedule/one', controllers.scheduleController.getSchedule)

// 比特量化部分
// 币安部分
router.get('/binance/getExchangeInfo', controllers.binanceController.getExchangeInfo)
router.get('/binance/getAccount', controllers.binanceController.getAccount)
router.get('/binance/getBalance', controllers.binanceController.getBalance)
router.get('/binance/getPrices', controllers.binanceController.getPrices)
router.get('/binance/getPricesByKey', controllers.binanceController.getPricesByKey)
router.get('/binance/marketBuy', controllers.binanceController.marketBuy)
router.get('/binance/marketSell', controllers.binanceController.marketSell)
router.get('/binance/kLines', controllers.binanceController.kLines)
router.get('/binance/kLinesAll', controllers.binanceController.kLinesAll)
router.get('/binance/futuresKLinesAll', controllers.binanceController.futuresKLinesAll)
router.get('/binance/kLinesAllWithTime', controllers.binanceController.kLinesAllWithTime)
router.get('/binance/kLinesAllOnlyTime', controllers.binanceController.kLinesAllOnlyTime)
// 获取交易规则
router.get('/binance/getFuturesExchangeInfo', controllers.binanceController.getFuturesExchangeInfo)
// 获取合约资产
router.get('/binance/getFuturesAccount', controllers.binanceController.getFuturesAccount)
// 获取价格
router.get('/binance/getFuturesPrices', controllers.binanceController.getFuturesPrices)
// 获取24小时交易情况
router.get('/binance/getFuturesDaily', controllers.binanceController.getFuturesDaily)
router.get('/binance/getFuturesBalance', controllers.binanceController.getFuturesBalance)
router.get('/binance/getFuturesPositionRisk', controllers.binanceController.getFuturesPositionRisk)
router.get('/binance/futuresLeverage', controllers.binanceController.futuresLeverage)
router.get('/binance/futuresMarketBuy', controllers.binanceController.futuresMarketBuy)
router.get('/binance/futuresMarketSell', controllers.binanceController.futuresMarketSell)
router.get('/binance/futuresBuy', controllers.binanceController.futuresBuy)
router.get('/binance/futuresSell', controllers.binanceController.futuresSell)
router.get('/binance/futuresCancel', controllers.binanceController.futuresCancel)
router.get('/binance/futuresCancelAll', controllers.binanceController.futuresCancelAll)
router.get('/binance/futuresAllOrders', controllers.binanceController.futuresAllOrders)
router.get('/binance/orderStatus', controllers.binanceController.orderStatus)
router.get('/binance/futuresOrderStatus', controllers.binanceController.futuresOrderStatus)
router.get('/binance/futuresMarginType', controllers.binanceController.futuresMarginType)
router.get('/binance/futuresQuote', controllers.binanceController.futuresQuote)
router.get('/binance/futuresDepth', controllers.binanceController.futuresDepth)
// 比特量化部分完成
// 指数部分
router.post('/btbIndex/addBtbIndex', controllers.userBtbController.addBtbIndex)
router.post('/btbIndex/deleteBtbIndex', controllers.userBtbController.deleteBtbIndex)
router.post('/btbIndex/updateBtbIndex', controllers.userBtbController.updateBtbIndex)
router.post('/btbIndex/changeBtbIndexStatus', controllers.userBtbController.changeBtbIndexStatus)
router.get('/btbIndex/getBtbIndexByPage', controllers.userBtbController.getBtbIndexByPage)
router.get('/btbIndex/getBtbIndexByCode', controllers.userBtbController.getBtbIndexByCode)
router.get('/btbIndex/getBtbIndexAll', controllers.userBtbController.getBtbIndexAll)
router.get('/btbIndex/getBtbIndexWithPosition', controllers.userBtbController.getBtbIndexWithPosition)
router.get('/btbIndex/updateBtbMonitor', controllers.userBtbController.updateBtbMonitor)
router.post('/btbIndex/updateBtbStrategy', controllers.userBtbController.updateBtbStrategy)
router.get('/btbIndex/getUsdtBtbIndex', controllers.userBtbController.getUsdtBtbIndex)
router.get('/btbIndex/getBtbMonitor', controllers.userBtbController.getBtbMonitor)
router.get('/btbIndex/findGoodBtbInMarket', controllers.userBtbController.findGoodBtbInMarket)
router.get('/btbIndex/findGoodBtbInMarketV2', controllers.userBtbController.findGoodBtbInMarketV2)
router.get('/btbIndex/preFindGoodBtbInMarket', controllers.userBtbController.preFindGoodBtbInMarket)
// 账户部分
router.get('/btbIndex/getMyBalanceInfo', controllers.userBtbController.getMyBalanceInfo)
router.get('/btbIndex/getAssetHY', controllers.userBtbController.getAssetHY)
router.get('/btbIndex/getMyBalanceInfoV2', controllers.userBtbController.getMyBalanceInfoV2)
// 量化部分
router.get('/btbIndex/checkBtbStatusMonth', controllers.userBtbController.checkBtbStatusMonth)
router.get('/btbIndex/checkBtbStatusWeek', controllers.userBtbController.checkBtbStatusWeek)
router.get('/btbIndex/checkBtbStatusDay', controllers.userBtbController.checkBtbStatusDay)
router.get('/btbIndex/checkBtbStatus4Hour', controllers.userBtbController.checkBtbStatus4Hour)
router.get('/btbIndex/checkBtbStatus1Hour', controllers.userBtbController.checkBtbStatus1Hour)
// 买卖部分
router.get('/btbIndex/buySellBtbXH15m', controllers.userBtbController.buySellBtbXH15m)
router.get('/btbIndex/buySellBtbHY15m', controllers.userBtbController.buySellBtbHY15m)
router.get('/btbIndex/buySellBtbHY15mV2', controllers.userBtbController.buySellBtbHY15mV2)
router.get('/btbIndex/changeLeverage', controllers.userBtbController.changeLeverage)
router.get('/btbIndex/closePositionHY', controllers.userBtbController.closePositionHY)
router.get('/btbIndex/closePositionHYV2', controllers.userBtbController.closePositionHYV2)
router.get('/btbIndex/closeAllPositionHY', controllers.userBtbController.closeAllPositionHY)
router.get('/btbIndex/closePositionXH', controllers.userBtbController.closePositionXH)
router.get('/btbIndex/closeAllPositionXH', controllers.userBtbController.closeAllPositionXH)
router.get('/btbIndex/quickBuyXH', controllers.userBtbController.quickBuyXH)
router.get('/btbIndex/getExecuteRecordsByPage', controllers.userBtbController.getExecuteRecordsByPage)
router.get('/btbIndex/getExecuteRecordsStatistics', controllers.userBtbController.getExecuteRecordsStatistics)
router.get('/btbIndex/deleteExpireExecuteRecord', controllers.userBtbController.deleteExpireExecuteRecord)
router.get('/btbIndex/deleteExecuteRecords', controllers.userBtbController.deleteExecuteRecords)
router.get('/btbIndex/reFormatExecuteRecords', controllers.userBtbController.reFormatExecuteRecords)
router.get('/btbIndex/getAssetRecordsByPage', controllers.userBtbController.getAssetRecordsByPage)
router.get('/btbIndex/addAssetRecord', controllers.userBtbController.addAssetRecord)
router.get('/btbIndex/getAssetRecordsByDay', controllers.userBtbController.getAssetRecordsByDay)
router.get('/btbIndex/getAssetStatistics', controllers.userBtbController.getAssetStatistics)
router.get('/btbIndex/getTradeStatisticsByDirection', controllers.userBtbController.getTradeStatisticsByDirection)
router.get('/btbIndex/deleteAssetRecords', controllers.userBtbController.deleteAssetRecords)
router.get('/btbIndex/countConditionStatistics', controllers.userBtbController.countConditionStatistics)
router.get('/btbIndex/analysisBtbTest', controllers.userBtbController.analysisBtbTest)
router.get('/btbIndex/analysisBtbBuySellTest', controllers.userBtbController.analysisBtbBuySellTest)
router.get('/btbIndex/getQuoteRecordsByDay', controllers.userBtbController.getQuoteRecordsByDay)
router.get('/btbIndex/getQuoteVolumeRecordsByPage', controllers.userBtbController.getQuoteVolumeRecordsByPage)
router.get('/btbIndex/getExecuteRecordDetail', controllers.userBtbController.getExecuteRecordDetail)
router.get('/btbIndex/getQuoteVolumeRecordDetail', controllers.userBtbController.getQuoteVolumeRecordDetail)
router.get('/btbIndex/reformatQuoteVolumeRecords', controllers.userBtbController.reformatQuoteVolumeRecords)
router.get('/btbIndex/findBtbByAnalysis', controllers.userBtbController.findBtbByAnalysis)
router.get('/btbIndex/getBtbWarnRecordsByPage', controllers.userBtbController.getBtbWarnRecordsByPage)
router.get('/btbIndex/getAssetRecordDetail', controllers.userBtbController.getAssetRecordDetail)
router.post('/btbIndex/remarkAssetRecord', controllers.userBtbController.remarkAssetRecord)
// 测试
router.get('/test/binanceApi', controllers.testController.binanceApi)
module.exports = router
